package com.pajk.user.api.http;

import java.security.Security;

import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.testng.Assert;
import org.testng.annotations.Test;

import com.pajk.test.api.BaseTest;
import com.pajk.test.client.ContextHelper;
import com.pingan.jk.api.request.ApiCode;
import com.pingan.jk.api.request.Device_Register;
import com.pingan.jk.client.ApiContext;
import com.pingan.jk.client.BaseRequest;
import com.pingan.jk.client.util.Base64Util;
import com.pingan.jk.logger.LoggerFactory;

public class Device_RegisterIT extends BaseTest {
    static {
    	LoggerFactory.setType("log4j");
        Security.addProvider(new BouncyCastleProvider());
    }
    
	@Test(description="device.register 设备注册 安全级别: None")
	public void registerTest(){
		String info =  "系统版本|设备型号|IMEI|mac||";
		ApiContext context = ContextHelper.getApiContext();
        Device_Register req1 = new Device_Register(info);
        ContextHelper.sendRequest(context, new BaseRequest[] { req1 });
        Assert.assertEquals(req1.getReturnCode() , ApiCode.SUCCESS);
        System.out.println("returnCode:"+req1.getReturnCode());
        byte[] bs = Base64Util.decode(req1.getResponse().certificate);
        context.setCertificateWithDeviceToken(bs, req1.getResponse().deviceToken);
        System.out.println("[registerDevice]deviceid:"+context.getDeviceId() + "  devicetoken:" + req1.getResponse().deviceToken + "   certificate:"+req1.getResponse().certificate);
	}
	
	@Test(description="device.register 设备注册 安全级别: None")
	public void register2Test(){
		super.registerDevice();
	}
}
